package library.and.xps.com.step.view.customview.WaveView;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;

public class WavePice implements BaseActiveElement {
    private Path path = new Path();
    private Paint paint;
    private Paint bgpaint;
    private int mWidth, mHeight;
    private int space = 300;
    private int radius = 400;
    private int increase = 50;
    private int useIncrease = 100;
    private float fUnknow;
    int gap;

    public WavePice(int gap, int width, int height) {
        mWidth = width;
        mHeight = height;
        this.gap = gap;
        paint = new Paint();
        bgpaint = new Paint();
        bgpaint.setAntiAlias(true);
        bgpaint.setColor(Color.parseColor("#06D5A6"));
        paint.setAntiAlias(true);
        paint.setColor(Color.WHITE);
        paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP));
    }

    @Override
    public void move() {

    }

    @Override
    public void SetX(float i) {
    }

    @Override
    public void SetY(float i) {
        fUnknow = i + (i / 2) + gap;
    }

    @Override
    public void draw(Canvas canvas) {

        canvas.drawRect(0, 0, mWidth, mHeight, bgpaint);

        path.reset();
        float y = mHeight - (mHeight / 2);//波浪起始位置

        path.moveTo(0, y);

        //x y x y
        path.rQuadTo(mWidth / 4 + (fUnknow / 2), -useIncrease - fUnknow, mWidth + (fUnknow / 2), 0);
       // path.rQuadTo(mWidth / 4 + (fUnknow / 2), useIncrease + fUnknow, mWidth + (fUnknow / 2), 0);

        path.lineTo(mWidth, y);
        path.lineTo(mWidth, mHeight);
        path.lineTo(0, mHeight);

        path.close();

        canvas.drawPath(path, paint);
    }
}
